home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Utilities / vim-5.1 / doc / map.txt < prev    next >
Encoding:
Text File  |  1998-04-05  |  20.7 KB  |  515 lines

  1. *map.txt*       For Vim version 5.1.  Last modification: 1998 Feb 26
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Key mapping and abbreviations.
  8.  
  9. 1. Key mapping        |key-mapping|
  10. 2. Abbreviations    |abbreviations|
  11.  
  12. ==============================================================================
  13. 1. Key mapping                        *key-mapping*
  14.  
  15. There are commands to enter new mappings, remove mappings and list mappings.
  16. See |map-overview| for the various forms of "map" and their relationships with
  17. modes.
  18.  
  19. :map     {lhs} {rhs}                    *:map*
  20. :nm[ap]  {lhs} {rhs}                    *:nm* *:nmap*
  21. :vm[ap]  {lhs} {rhs}                    *:vm* *:vmap*
  22. :om[ap]  {lhs} {rhs}                    *:om* *:omap*
  23. :map!    {lhs} {rhs}                    *:map!*
  24. :im[ap]  {lhs} {rhs}                    *:im* *:imap*
  25. :cm[ap]  {lhs} {rhs}                    *:cm* *:cmap*
  26.             Map the key sequence {lhs} to {rhs} for the modes
  27.             where the map command applies.  The result, including
  28.             {rhs}, is then further scanned for mappings.  This
  29.             allows for nested and recursive use of mappings.
  30.  
  31.  
  32. :no[remap]   {lhs} {rhs}                *:no*  *:noremap*
  33. :nn[oremap]  {lhs} {rhs}                *:nn*  *:nnoremap*
  34. :vn[oremap]  {lhs} {rhs}                *:vn*  *:vnoremap*
  35. :ono[remap]  {lhs} {rhs}                *:ono* *:onoremap*
  36. :no[remap]!  {lhs} {rhs}                *:no!* *:noremap!*
  37. :ino[remap]  {lhs} {rhs}                *:ino* *:inoremap*
  38. :cno[remap]  {lhs} {rhs}                *:cno* *:cnoremap*
  39.             Map the key sequence {lhs} to {rhs} for the modes
  40.             where the map command applies.  Disallow mapping of
  41.             {rhs}, to avoid nested and recursive mappings.  Often
  42.             used to redefine a command.  {not in Vi}
  43.  
  44.  
  45. :unm[ap]   {lhs}                    *:unm*  *:unmap*
  46. :nun[map]  {lhs}                    *:nun*  *:nunmap*
  47. :vu[nmap]  {lhs}                    *:vu*   *:vunmap*
  48. :ou[nmap]  {lhs}                    *:ou*   *:ounmap*
  49. :unm[ap]!  {lhs}                    *:unm!* *:unmap!*
  50. :iu[nmap]  {lhs}                    *:iu*   *:iunmap*
  51. :cu[nmap]  {lhs}                    *:cu*   *:cunmap*
  52.             Remove the mapping of {lhs} for the modes where the
  53.             map command applies.  The mapping may remain defined
  54.             for other modes where it applies.
  55.             Note: Trailing spaces are included in the {lhs}.  This
  56.             unmap does NOT work:
  57. >                :map @@ foo
  58. >                :unmap @@ | print
  59.  
  60. :mapc[lear]                        *:mapc*   *:mapclear*
  61. :nmapc[lear]                        *:nmapc*  *:nmapclear*
  62. :vmapc[lear]                        *:vmapc*  *:vmapclear*
  63. :omapc[lear]                        *:omapc*  *:omapclear*
  64. :mapc[lear]!                        *:mapc!*  *:mapclear!*
  65. :imapc[lear]                        *:imapc*  *:imapclear*
  66. :cmapc[lear]                        *:cmapc*  *:cmapclear*
  67.             Remove ALL mappings for the modes where the map
  68.             command applies.  {not in Vi}
  69.  
  70. :map
  71. :nm[ap]
  72. :vm[ap]
  73. :om[ap]
  74. :map!
  75. :im[ap]
  76. :cm[ap]
  77.             List all key mappings for the modes where the map
  78.             command applies.  Note that ":map" and ":map!" are
  79.             used most often, because they include the other modes.
  80.  
  81. :map     {lhs}                        *:map_l*
  82. :nm[ap]  {lhs}                        *:nmap_l*
  83. :vm[ap]  {lhs}                        *:vmap_l*
  84. :om[ap]  {lhs}                        *:omap_l*
  85. :map!    {lhs}                        *:map_l!*
  86. :im[ap]  {lhs}                        *:imap_l*
  87. :cm[ap]  {lhs}                        *:cmap_l*
  88.             List the key mappings for the key sequences starting
  89.             with {lhs} in the modes where the map command applies.
  90.             {not in Vi}
  91.  
  92. These commands are used to map a key or key sequence to a string of
  93. characters.  You can use this to put command sequences under function keys,
  94. translate one key into another, etc.  See |:mkexrc| for how to save and
  95. restore the current mappings.
  96.  
  97. There are five sets of mappings
  98. - For Normal mode: When typing commands.
  99. - For Visual mode: When typing commands while the Visual area is highlighted.
  100. - For Operator-pending mode: When an operator is pending (after "d", "y", "c",
  101.   etc.).
  102. - For Insert mode. These are also used in Replace mode.
  103. - For Command-line mode: When entering a ":" or "/" command.
  104.  
  105.                         *map-overview* *map-modes*
  106. Overview of which map command works in which mode:
  107.  
  108.     commands:                      modes:                  ~
  109.                       Normal     Visual  Operator-pending ~
  110. :map   :noremap   :unmap   :mapclear         X        X       X
  111. :nmap  :nnoremap  :nunmap  :nmapclear        X           .            .
  112. :vmap  :vnoremap  :vunmap  :vmapclear        .           X          .
  113. :omap  :onoremap  :ounmap  :omapclear        .             .          X
  114.  
  115.                       Insert Command-line        ~
  116. :map!  :noremap!  :unmap!  :mapclear!        X         X
  117. :imap  :inoremap  :iunmap  :imapclear        X         .
  118. :cmap  :cnoremap  :cunmap  :cmapclear        .         X
  119.  
  120. The original Vi did not have separate mappings for
  121. Normal/Visual/Operator-pending mode and for Insert/Command-line mode.
  122. Therefore the ":map" and ":map!" commands enter and display mappings for
  123. several modes.  In Vim you can use the ":nmap", ":vmap", ":omap", ":cmap" and
  124. ":imap" commands to enter mappings for each mode separately.
  125.  
  126. To enter a mapping for Normal and Visual mode, but not Operator-pending mode,
  127. first define it for all three modes, then unmap it for Operator-pending mode:
  128.     :map    xx something-difficult
  129.     :ounmap xx
  130. Likewise for a mapping for Visual and Operator-pending mode or Normal and
  131. Operator-pending mode.
  132.  
  133.                             *map-listing*
  134. When listing mappings the characters in the first two columns are:
  135.  
  136.     CHAR        MODE    ~
  137.     <Space>        Normal, Visual and Operator-pending
  138.      n        Normal
  139.      v        Visual
  140.      o        Operator-pending
  141.      !        Insert and Command-line
  142.      i        Insert
  143.      c        Command-line
  144.  
  145. A "*" just before the {rhs} indicates that it is not remappable.
  146.  
  147. Everything from the first non-blank after {lhs} up to the end of the line
  148. (or '|') is considered to be part of {rhs}.  This allows the {rhs} to end
  149. with a space.
  150.  
  151. Note: When using mappings for Visual mode, you can use the "'<" mark, which
  152. is the start of the last selected Visual area in the current buffer |'<|.
  153.  
  154.                             *map_backslash*
  155. Note that only CTRL-V is mentioned here as a special character for mappings
  156. and abbreviations.  When 'cpoptions' does not contain 'B', a backslash can
  157. also be used like CTRL-V.  The <> notation can be fully used then |<>|.  But
  158. you cannot use "<C-V>" like CTRL-V to escape the special meaning of what
  159. follows.
  160.  
  161. To map a backslash, or use a backslash literally in the {rhs}, the special
  162. sequence "<Bslash>" can be used.  This avoids the need to double backslashes
  163. when using nested mappings.
  164.  
  165.                             *map_CTRL_C*
  166. It's not possible to use a CTRL-C in the {lhs}.  You just can't map CTRL-C.
  167. The reason is that CTRL-C must always be available to break a running command.
  168.  
  169.                             *map_space_in_lhs*
  170. To include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for
  171. each space).
  172.                             *map_space_in_rhs*
  173. If you want a {rhs} that starts with a space, use "<Space>".  To be fully Vi
  174. compatible (but unreadable) don't use the |<>| notation, precede {rhs} with a
  175. single CTRL-V (you have to type CTRL-V two times).
  176.                             *map_empty_rhs*
  177. You can create an empty {rhs} by typing nothing after a single CTRL-V (you
  178. have to type CTRL-V two times).  Unfortunately, you cannot do this in a vimrc
  179. file.
  180.                             *map-comments*
  181. It is not possible to put a comment after these commands, because the '"'
  182. character is considered to be part of the {lhs} or {rhs}.
  183.  
  184.                             *map_bar*
  185. Since the '|' character is used to separate a map command from the next
  186. command, you will have to do something special to include  a '|' in {rhs}.
  187. There are three methods:
  188.    use       works when                    example    ~
  189.    <Bar>     '<' is not in 'cpoptions'     :map _l :!ls <Bar> more^M
  190.    \|        'b' is not in 'cpoptions'     :map _l :!ls \| more^M
  191.    ^V|       always, in Vim and Vi         :map _l :!ls ^V| more^M
  192.  
  193. (here ^V stands for CTRL-V; to get one CTRL-V you have to type it twice; you
  194. cannot use the <> notation "<C-V>" here).
  195.  
  196. All three work when you use the default setting for 'cpoptions'.
  197.  
  198. When 'b' is present in 'cpoptions', "\|" will be recognized as a mapping
  199. ending in a '\' and then another command.  This is Vi compatible, but
  200. unlogical when compared to other commands.
  201.  
  202.                             *map_return*
  203. When you have a mapping that contains an Ex command, you need to put a line
  204. terminator after it to have it executed.  The use of <CR> is recommended for
  205. this (see |<>|).  Example:
  206. >  :map  _ls  :!ls -l %<CR>:echo "the end"<CR>
  207.  
  208. To avoid mapping of the characters you type in insert or Command-line mode,
  209. type a CTRL-V first.  The mapping in Insert mode is disabled if the 'paste'
  210. option is on.
  211.  
  212. Note that when an error is enountered (that causes an error message) the rest
  213. of the mapping is not executed.  This is Vi-compatible.
  214.  
  215. Note that the second character (argument) of the commands @zZtTfF[]rm'`"v
  216. and CTRL-X is not mapped.  This was done to be able to use all the named
  217. registers and marks, even when the command with the same name has been
  218. mapped.
  219.  
  220.                             *map-which-keys*
  221. If you are going to map something, you will need to choose which key(s) to use
  222. for the {lhs}.  You will have to avoid keys that are used for Vim commands,
  223. otherwise you would not be able to use those commands anymore.  Here are a few
  224. suggestions:
  225. - Function keys <F2>, <F3>, etc..  Also the shifted function keys.  Note that
  226.   <F1> is already used for the help command.
  227. - Meta-keys (with the ALT key pressed).
  228. - Use the "_" character and then any other character.  The "_" command does
  229.   exist in Vim (see |_|), but you probably never use it.
  230.  
  231.                             *map-examples*
  232. A few examples (given as you type them, for "<CR>" you type four characters;
  233. the '<' flag must not be present in 'cpoptions' for this to work).
  234.  
  235. >  :map <F3>  o#include
  236. >  :map <M-g> /foo<CR>cwbar<Esc>
  237. >  :map _x    d/END/e<CR>
  238. >  :map! qq   quadrillion questions
  239.  
  240.                             *map-typing*
  241. Vim will compare what you type with the start of a mapped sequence.  If there
  242. is an incomplete match, it will get more characters until there either is a
  243. complete match or until there is no match at all.  Example: If you map! "qq",
  244. the first 'q' will not appear on the screen until you type another
  245. character.  This is because Vim cannot know if the next character will be a
  246. 'q' or not.  If the 'timeout' option is on (which is the default) Vim will
  247. only wait for one second (or as long as specified with the 'timeoutlen'
  248. option).  After that it assumes that the 'q' is to be interpreted as such.  If
  249. type slowly, or your system is slow, reset the 'timeout' option.  Then you
  250. might want to set the 'ttimeout' option.
  251.  
  252.                         *recursive_mapping*
  253. If you include the {lhs} in the {rhs} you have a recursive mapping.  When
  254. {lhs} is typed, it will be replaced with {rhs}.  When the {lhs} which is
  255. included in {rhs} is encountered it will be replaced with {rhs}, and so on.
  256. This makes it possible to repeat a command an infinite number of times.  The
  257. only problem is that the only way to stop this is by causing an error.  The
  258. macros to solve a maze uses this, look there for an example.  There is one
  259. exception: If the {rhs} starts with {lhs}, the first character is not mapped
  260. again (this is Vi compatible).
  261. For example:
  262. >  :map ab abcd
  263. will execute the "a" command and insert "bcd" in the text.  The "ab" in the
  264. {rhs} will not be mapped again.
  265.  
  266. If you want to exchange the meaning of two keys you should use the :noremap
  267. command.  For example:
  268. >  :noremap k j
  269. >  :noremap j k
  270. This will exchange the cursor up and down commands.
  271.  
  272. With the normal :map command, when the 'remap' option is on, mapping takes
  273. place until the text is found not to be a part of a {lhs}.  For example, if
  274. you use:
  275. >  :map x y
  276. >  :map y x
  277. Vim will replace x with y, and then y with x, etc.  When this has happened
  278. 'maxmapdepth' times (default 1000), Vim will give the error message
  279. "recursive mapping".
  280.  
  281. See the file "index" for keys that are not used and thus can be mapped
  282. without losing any builtin function.  I suggest you use function keys,
  283. and meta-keys.  If you are prepared to lose a command that you hardly ever use
  284. you can make mappings that start with '_' or '-'.  You can also use
  285. ":help <key>^D" to find out if a key is used for some command.  (<key> is the
  286. specific key you want to find out about, ^D is CTRL-D).
  287.  
  288. If you include an undo command inside a mapped sequence, this will bring the
  289. text back in the state before executing the macro.  This is compatible with
  290. the original Vi, as long as there is only one undo command in the mapped
  291. sequence (having two undo commands in a mapped sequence did not make sense
  292. in the original Vi, you would get back the text before the first undo).
  293.  
  294. There are three ways to map a special key:
  295. 1. The Vi-compatible method: Map the key code.  Often this is a sequence that
  296.    starts with <Esc>.  To enter a mapping like this you type ":map " and then
  297.    you have to type CTRL-V before hitting the function key.  Note that when
  298.    the key code for the key is in the termcap (the t_ options), it will
  299.    automatically be translated into the internal code and become the second
  300.    way of mapping (unless the 'k' flag is included in 'cpoptions').
  301. 2. The second method is to use the internal code for the function key.  To
  302.    enter such a mapping type CTRL-K and then hit the function key, or use
  303.    the form "#1", "#2", .. "#9", "#0", "<Up>", "<S-Down>", "<S-F7>", etc.
  304.    (see table of keys |key-notation|, all keys from <Up> can be used).  The
  305.    first ten function keys can be defined in two ways: Just the number, like
  306.    "#2", and with "<F>", like "<F2>".  Both stand for function key 2.  "#0"
  307.    refers to function key 10, defined with option 't_f10', which may be
  308.    function key zero on some keyboards.  The <> form cannot be used when
  309.    'cpoptions' includes the '<' flag.
  310. 3. Use the termcap entry, with the form <t_xx>, where "xx" is the name of the
  311.    termcap entry.  Any string entry can be used.  For example:
  312. >    :map <t_F3> G
  313.    Maps function key 13 to "G".  This does not work if 'cpoptions' includes
  314.    the '<' flag.
  315.  
  316. The advantage of the second and third method is that the mapping will work on
  317. different terminals without modification (the function key will be
  318. translated into the same internal code or the actual key code, no matter what
  319. terminal you are using.  The termcap must be correct for this to work, and you
  320. must use the same mappings).
  321.  
  322. DETAIL: Vim first checks if a sequence from the keyboard is mapped.  If it
  323. isn't the terminal key codes are tried (see |terminal-options|).  If a
  324. terminal code is found it is replaced with the internal code.  Then the check
  325. for a mapping is done again (so you can map an internal code to something
  326. else).  What is written into the script file depends on what is recognized.
  327. If the terminal key code was recognized as a mapping the key code itself is
  328. written to the script file.  If it was recognized as a terminal code the
  329. internal code is written to the script file.
  330.  
  331. ==============================================================================
  332. 2. Abbreviations                    *abbreviations*
  333.  
  334. Abbreviations are used in insert mode, Replace mode and Command-line mode.
  335. If you enter a word that is an abbreviation, it is replaced with the word it
  336. stands for.  This can be used to save typing for often used long words.
  337.  
  338. There are three types of abbreviations:
  339.  
  340. full-id      The "full-id" type consists entirely of keyword characters (letters
  341.       and characters from 'iskeyword' option).  This is the most common
  342.       abbreviation.
  343.  
  344.       Examples: "foo", "g3", "-1"
  345.  
  346. end-id      The "end-id" type ends in a keyword character, but all the other
  347.       characters are not keyword characters.
  348.  
  349.       Examples: "#i", "..f", "$/7"
  350.  
  351. non-id      The "non-id" type ends in a non-keyword character, the other
  352.       characters may be of any type, excluding space and Tab.  {this type
  353.       is not supported by Vi}
  354.  
  355.       Examples: "def#", "4/7$"
  356.  
  357. Examples of strings that cannot be abbreviations: "a.b", "#def", "a b", "_$r"
  358.  
  359. An abbreviation is only recognized when you type a non-keyword character.
  360. This can also be the <Esc> that ends insert mode or the <CR> that ends a
  361. command.  The non-keyword character which ends the abbreviation is inserted
  362. after the expanded abbreviation.  An exception to this is the character <C-]>,
  363. which is used to expand an abbreviation without inserting any extra
  364. characters.
  365.  
  366. Example:
  367. >   :ab hh    hello
  368.         "hh<Space>" is expanded to "hello<Space>"
  369.         "hh<C-]>" is expanded to "hello"
  370.  
  371. The characters before the cursor must match the abbreviation.  Each type has
  372. an additional rule:
  373.  
  374. full-id      In front of the match is a non-keyword character, or this is where
  375.       the line or insertion starts.  Exception: When the abbreviation is
  376.       only one character, it is not recognized if there is a non-keyword
  377.       character in front of it, other than a space or a <Tab>.
  378.  
  379. end-id      In front of the match is a keyword character, or a space or a <Tab>,
  380.       or this is where the line or insertion starts.
  381.  
  382. non-id      In front of the match is a space, <Tab> or the start of the line or
  383.       the insertion.
  384.  
  385. Examples: (<CURSOR> is where you type a non-keyword character)
  386. >  :ab foo   four old otters
  387.         " foo<CURSOR>"      is expanded to " four old otters"
  388.         " foobar<CURSOR>" is not expanded
  389.         "barfoo<CURSOR>"  is not expanded
  390.  
  391. >  :ab #i #include
  392.         "#i<CURSOR>"      is expanded to "#include"
  393.         ">#i<CURSOR>"      is not expanded
  394.  
  395. >  :ab ;; <endofline>"
  396.         "test;;"      is not expanded
  397.         "test ;;"      is expanded to "test <endofline>"
  398.  
  399. To avoid the abbreviation in insert mode: Type part of the abbreviation, exit
  400. insert mode with <Esc>, re-enter insert mode with "a" and type the rest.  Or
  401. type CTRL-V before the character after the abbreviation.
  402. To avoid the abbreviation in Command-line mode: Type CTRL-V twice somewhere in
  403. the abbreviation to avoid it to be replaced.  A CTRL-V in front of a normal
  404. character is mostly ignored otherwise.
  405.  
  406. There are no default abbreviations.
  407.  
  408. Abbreviations are never recursive.  You can use ":ab f f-o-o" without any
  409. problem.  But abbreviations can be mapped.  {some versions of Vi support
  410. recursive abbreviations, for no apparent reason}
  411.  
  412. Abbreviations are disabled if the 'paste' option is on.
  413.  
  414.                         *:ab* *:abbreviate*
  415. :ab[breviate]        list all abbreviations.  The character in the first
  416.             column indicates the mode where the abbreviation is
  417.             used: 'i' for insert mode, 'c' for Command-line
  418.             mode, '!' for both.
  419.  
  420. :ab[breviate] <lhs>    list the abbreviations that start with <lhs>
  421.  
  422. :ab[breviate] <lhs> <rhs>
  423.             add abbreviation for <lhs> to <rhs>.  If <lhs> already
  424.             existed it is replaced with the new <rhs>.  <rhs> may
  425.             contain spaces.
  426.  
  427.                         *:una* *:unabbreviate*
  428. :una[bbreviate] <lhs>    remove abbreviation for <lhs> from the list
  429.  
  430.                         *:norea* *:noreabbrev*
  431. :norea[bbrev] [lhs] [rhs]
  432.             same as ":ab", but no remapping for this <rhs> {not
  433.             in Vi}
  434.  
  435.                         *:ca* *:cabbrev*
  436. :ca[bbrev] [lhs] [rhs]    same as ":ab", but for Command-line mode only.  {not
  437.             in Vi}
  438.  
  439.                         *:cuna* *:cunabbrev*
  440. :cuna[bbrev] <lhs>    same as ":una", but for Command-line mode only.  {not
  441.             in Vi}
  442.  
  443.                         *:cnorea* *:cnoreabbrev*
  444. :cnorea[bbrev] [lhs] [rhs]
  445.             same as ":ab", but for Command-line mode only and no
  446.             remapping for this <rhs> {not in Vi}
  447.  
  448.                         *:ia* *:iabbrev*
  449. :ia[bbrev] [lhs] [rhs]    same as ":ab", but for Insert mode only.  {not in Vi}
  450.  
  451.                         *:iuna* *:iunabbrev*
  452. :iuna[bbrev] <lhs>    same as ":una", but for insert mode only.  {not in
  453.             Vi}
  454.  
  455.                         *:inorea* *:inoreabbrev*
  456. :inorea[bbrev] [lhs] [rhs]
  457.             same as ":ab", but for Insert mode only and no
  458.             remapping for this <rhs> {not in Vi}
  459.  
  460.                             *:abc* *:abclear*
  461. :abc[lear]        Remove all abbreviations.  {not in Vi}
  462.  
  463.                             *:iabc* *:iabclear*
  464. :iabc[lear]        Remove all abbreviations for Insert mode.  {not in Vi}
  465.  
  466.                             *:cabc* *:cabclear*
  467. :cabc[lear]        Remove all abbreviations for Command-line mode.  {not
  468.             in Vi}
  469.  
  470.                             *using_CTRL-V*
  471. It is possible to use special characters in the rhs of an abbreviation.
  472. CTRL-V has to be used to avoid the special meaning of most non printable
  473. characters.  How many CTRL-Vs need to be typed depends on how you enter the
  474. abbreviation.  This also applies to mappings.  Let's use an example here.
  475.  
  476. Suppose you want to abbreviate "esc" to enter an <Esc> character.  When you
  477. type the ":ab" command in Vim, you have to enter this: (here ^V is a CTRL-V
  478. and ^[ is <Esc>)
  479.  
  480. You type:   ab esc ^V^V^V^V^V^[
  481.  
  482.     All keyboard input is subjected to ^V quote interpretation, so
  483.     the first, third, and fifth ^V  characters simply allow the second,
  484.     and fourth ^Vs, and the ^[, to be entered into the command line.
  485.  
  486. You see:    ab esc ^V^V^[
  487.  
  488.     The command line contains two actual ^Vs before the ^[.  This is
  489.     how it should appear in your .exrc file, if you choose to go that
  490.     route.  The first ^V is there to quote the second ^V; the :ab
  491.     command uses ^V as its own quote character, so you can include quoted
  492.     whitespace or the | character in the abbreviation.   The :ab command
  493.     doesn't do anything special with the ^[ character, so it doesn't need
  494.     to be quoted.  (Although quoting isn't harmful; that's why typing 7
  495.     [but not 8!] ^Vs works.)
  496.  
  497. Stored as:  esc     ^V^[
  498.  
  499.     After parsing, the abbreviation's short form ("esc") and long form
  500.     (the two characters "^V^[") are stored in the abbreviation table.
  501.     If you give the :ab command with no arguments, this is how the
  502.     abbreviation will be displayed.
  503.  
  504.     Later, when the abbreviation is expanded because the user typed in
  505.     the word "esc", the long form is subjected to the same type of
  506.     ^V interpretation as keyboard input.  So the ^V protects the ^[
  507.     character from being interpreted as the "exit input-mode" character.
  508.     Instead, the ^[ is inserted into the text.
  509.  
  510. Expands to: ^[
  511.  
  512. [example given by Steve Kirkendall]
  513.  
  514.  vim:tw=78:ts=8:sw=8:
  515.